package com.yygo.model;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by tiansha on 2015/11/6.
 */
@Entity
@Table(name = "material")
public class Material extends BaseObject {

    private static final long serialVersionUID = -3763039739575816248L;
    private Long id;
    private String name;

    private boolean sent;
    private Date sendDate;
    private String shipNumber;

    private boolean received;
    private Date receiveDate;
    private String receiveOperator;
    private boolean started=false;

    private boolean isLoanRequest;

    private MaterialAudit materialAudit;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name="name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name="sent")
    public boolean isSent() {
        return sent;
    }

    public void setSent(boolean sent) {
        this.sent = sent;
    }

    @Column(name="send_date")
    public Date getSendDate() {
        return sendDate;
    }

    public void setSendDate(Date sendDate) {
        this.sendDate = sendDate;
    }

    @Column(name="ship_number")
    public String getShipNumber() {
        return shipNumber;
    }

    public void setShipNumber(String shipNumber) {
        this.shipNumber = shipNumber;
    }

    @Column(name="received")
    public boolean isReceived() {
        return received;
    }

    public void setReceived(boolean received) {
        this.received = received;
    }


    @Column(name="receive_date")
    public Date getReceiveDate() {
        return receiveDate;
    }

    public void setReceiveDate(Date receiveDate) {
        this.receiveDate = receiveDate;
    }

    @Column(name="receive_operator")
    public String getReceiveOperator() {
        return receiveOperator;
    }

    public void setReceiveOperator(String receiveOperator) {
        this.receiveOperator = receiveOperator;
    }

    @Transient
    public boolean isLoanRequest() {
        return isLoanRequest;
    }

    public void setIsLoanRequest(boolean isLoanRequest) {
        this.isLoanRequest = isLoanRequest;
    }

    @ManyToOne
    @JoinColumn(name="material_audit_id")
    public MaterialAudit getMaterialAudit() {
        return materialAudit;
    }

    public void setMaterialAudit(MaterialAudit materialAudit) {
        this.materialAudit = materialAudit;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Material material = (Material) o;

        if (name.equals(material.name)) {
            return true;
        }

        return false;
    }

    public int hashCode() {
        int result = 3;
        result = 57 * result + (name != null ? name.hashCode() : 0);
        return result;
    }

    public String toString() {
        return "Material{" +
                "name=" + name +
                '}';
    }
}
